<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>12.3. copy_reg — Register pickle support functions &mdash; Python v2.6.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.6.2',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python v2.6.2 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python v2.6.2 documentation" href="../index.html" />
    <link rel="up" title="12. Data Persistence" href="persistence.html" />
    <link rel="next" title="12.4. shelve — Python object persistence" href="shelve.html" />
    <link rel="prev" title="12.1. pickle — Python object serialization" href="pickle.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="shelve.html" title="12.4. shelve — Python object persistence"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="pickle.html" title="12.1. pickle — Python object serialization"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v2.6.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="persistence.html" accesskey="U">12. Data Persistence</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-copy_reg">
<h1>12.3. <tt class="xref docutils literal"><span class="pre">copy_reg</span></tt> &#8212; Register <a title="Convert Python objects to streams of bytes and back." class="reference external" href="pickle.html#module-pickle"><tt class="xref docutils literal"><span class="pre">pickle</span></tt></a> support functions<a class="headerlink" href="#module-copy_reg" title="Permalink to this headline">¶</a></h1>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <tt class="xref docutils literal"><span class="pre">copy_reg</span></tt> module has been renamed to <tt class="xref docutils literal"><span class="pre">copyreg</span></tt> in Python 3.0.
The <a class="reference external" href="../glossary.html#term-to3"><em class="xref">2to3</em></a> tool will automatically adapt imports when converting your
sources to 3.0.</p>
</div>
<p id="index-245">The <tt class="xref docutils literal"><span class="pre">copy_reg</span></tt> module provides support for the <a title="Convert Python objects to streams of bytes and back." class="reference external" href="pickle.html#module-pickle"><tt class="xref docutils literal"><span class="pre">pickle</span></tt></a> and
<a title="Faster version of pickle, but not subclassable." class="reference external" href="pickle.html#module-cPickle"><tt class="xref docutils literal"><span class="pre">cPickle</span></tt></a> modules.  The <a title="Shallow and deep copy operations." class="reference external" href="copy.html#module-copy"><tt class="xref docutils literal"><span class="pre">copy</span></tt></a> module is likely to use this in the
future as well.  It provides configuration information about object constructors
which are not classes.  Such constructors may be factory functions or class
instances.</p>
<dl class="function">
<dt id="copy_reg.constructor">
<tt class="descclassname">copy_reg.</tt><tt class="descname">constructor</tt><big>(</big><em>object</em><big>)</big><a class="headerlink" href="#copy_reg.constructor" title="Permalink to this definition">¶</a></dt>
<dd>Declares <em>object</em> to be a valid constructor.  If <em>object</em> is not callable (and
hence not valid as a constructor), raises <a title="exceptions.TypeError" class="reference external" href="exceptions.html#exceptions.TypeError"><tt class="xref docutils literal"><span class="pre">TypeError</span></tt></a>.</dd></dl>

<dl class="function">
<dt id="copy_reg.pickle">
<tt class="descclassname">copy_reg.</tt><tt class="descname">pickle</tt><big>(</big><em>type</em>, <em>function</em><span class="optional">[</span>, <em>constructor</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#copy_reg.pickle" title="Permalink to this definition">¶</a></dt>
<dd><p>Declares that <em>function</em> should be used as a &#8220;reduction&#8221; function for objects of
type <em>type</em>; <em>type</em> must not be a &#8220;classic&#8221; class object.  (Classic classes are
handled differently; see the documentation for the <a title="Convert Python objects to streams of bytes and back." class="reference external" href="pickle.html#module-pickle"><tt class="xref docutils literal"><span class="pre">pickle</span></tt></a> module for
details.)  <em>function</em> should return either a string or a tuple containing two or
three elements.</p>
<p>The optional <em>constructor</em> parameter, if provided, is a callable object which
can be used to reconstruct the object when called with the tuple of arguments
returned by <em>function</em> at pickling time.  <a title="exceptions.TypeError" class="reference external" href="exceptions.html#exceptions.TypeError"><tt class="xref docutils literal"><span class="pre">TypeError</span></tt></a> will be raised if
<em>object</em> is a class or <em>constructor</em> is not callable.</p>
<p>See the <a title="Convert Python objects to streams of bytes and back." class="reference external" href="pickle.html#module-pickle"><tt class="xref docutils literal"><span class="pre">pickle</span></tt></a> module for more details on the interface expected of
<em>function</em> and <em>constructor</em>.</p>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="pickle.html"
                                  title="previous chapter">12.1. <tt class="docutils literal"><span class="pre">pickle</span></tt> &#8212; Python object serialization</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="shelve.html"
                                  title="next chapter">12.4. <tt class="docutils literal"><span class="pre">shelve</span></tt> &#8212; Python object persistence</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/library/copy_reg.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="shelve.html" title="12.4. shelve — Python object persistence"
             >next</a> |</li>
        <li class="right" >
          <a href="pickle.html" title="12.1. pickle — Python object serialization"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v2.6.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="persistence.html" >12. Data Persistence</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; <a href="../copyright.html">Copyright</a> 1990-2009, Python Software Foundation.
      Last updated on Apr 15, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.
    </div>
  </body>
</html>